home *** CD-ROM | disk | FTP | other *** search
Oberon Text | 1996-04-09 | 4.3 KB | 85 lines |
- Syntax10.Scn.Fnt
- Syntax10i.Scn.Fnt
- StampElems
- Alloc
- 9 Apr 96
- Syntax10m.Scn.Fnt
- Syntax12i.Scn.Fnt
- LineElems
- Alloc
- MODULE Host; (** SHML 19 Mar 96,
- This module encapsulates all system dependent variables and procedures of an Oberon System V4.
- This is the version for Oberon for Amiga.
- Created by Stefan H._M. Ludwig, Institute for Computer Systems, ETH Zurich, ludwig@inf.ethz.ch, 19 Mar 96
- IMPORT Input, Display, Modules;
- Host-: ARRAY 32 OF CHAR; (** string identifying the host machine *)
- TimeUnit-: LONGINT; (** resolution of Input.Time(), TimeUnit ticks happen per second *)
- OptionChar-: CHAR; (** character used by command interpreters for specifying options *)
- PathChar-: CHAR; (** character used in file names for separating subdirectories *)
- backed: BOOLEAN;
- (* Support *)
- PROCEDURE Append(VAR to(*inout*): ARRAY OF CHAR; this: ARRAY OF CHAR);
- (* append this to to, trim this to space left in to *)
- VAR toLen, i, j: LONGINT;
- BEGIN
- i := -1;
- REPEAT INC(i) UNTIL to[i] = 0X;
- toLen := LEN(to)-1; j := 0;
- WHILE (i # toLen) & (this[j] # 0X) DO to[i] := this[j]; INC(i); INC(j) END;
- to[i] := 0X
- END Append;
- (* Exported procedures *)
- PROCEDURE Backup*(X, Y, W, H: INTEGER);
- (** Backup screen area X, Y, W, H; (must be followed by Restore, 100) *)
- BEGIN
- ASSERT(~backed, 100);
- backed := TRUE;
- Display.CopyBlock(X, Y, W, H, X, -H, Display.replace) (* backup into secondary bitmap *)
- END Backup;
- PROCEDURE Restore*(X, Y, W, H: INTEGER);
- (** Restore screen area X, Y, W, H; (must be preceded by Backup, 100) *)
- BEGIN
- ASSERT(backed, 100);
- backed := FALSE;
- Display.CopyBlock(X, -H, W, H, X, Y, Display.replace) (* restore from secondary bitmap *)
- END Restore;
- PROCEDURE IsFileNameChar*(ch: CHAR): BOOLEAN; (** Is ch part of a valid file name? *)
- BEGIN
- CASE ch OF
- | "A".."Z", "a".."z", "0".."9", ".", "/", "_", ":": RETURN TRUE
- ELSE RETURN FALSE
- END
- END IsFileNameChar;
- PROCEDURE CallError*(command: ARRAY OF CHAR; res: INTEGER; VAR msg(*out*): ARRAY OF CHAR);
- (** Translate error message when the call of command fails; (res # 0, 100); (LEN(msg) >= 32, 101) *)
- VAR i, j: INTEGER;
- BEGIN
- ASSERT(res # 0, 100); ASSERT(LEN(msg) >= 32, 101);
- IF res > 0 THEN
- COPY("Call error: ", msg); Append(msg, Modules.importing);
- IF res = 1 THEN Append(msg, " not found")
- ELSIF res = 2 THEN Append(msg, " not an obj-file")
- ELSIF res = 3 THEN
- Append(msg, " imports ");
- Append(msg, Modules.imported); Append(msg, " with bad key")
- ELSIF res = 4 THEN Append(msg, " corrupted obj file")
- ELSIF res = 5 THEN Append(msg, command); Append(msg, " command not found")
- ELSIF res = 6 THEN Append(msg, " has too many imports")
- ELSIF res = 7 THEN Append(msg, " not enough space")
- END
- ELSIF res < 0 THEN
- i := -1;
- REPEAT INC(i) UNTIL (command[i] = ".") OR (command[i] = 0X);
- IF command[i] = 0X THEN i := -1 END;
- j := -1;
- REPEAT INC(i); INC(j); msg[j] := command[i] UNTIL command[i] = 0X; (* copy procedure name *)
- Append(msg, " not found")
- END
- END CallError;
- BEGIN
- Host := "Amiga";
- OptionChar := "\"; PathChar := "/";
- TimeUnit := Input.TimeUnit;
- backed := FALSE
- END Host.
-